import { Column, Entity, ManyToOne, OneToOne } from 'typeorm'

import { BaseModelsWithUUIDPrimary, UserEntity, RoleEntity } from './index'

/**
 * @package 账号信息
 * @author liu
 */
@Entity({ name: 'auth' })
export class AuthEntity extends BaseModelsWithUUIDPrimary {
  @Column({ length: 20, unique: true, comment: '用户名' })
  username: string

  @Column({ length: 20, comment: '密码', select: false })
  password: string

  @Column({ default: 0, comment: '状态', select: false })
  status: boolean

  @OneToOne(() => UserEntity, user => user.login)
  user: UserEntity

  @ManyToOne(type => RoleEntity, role => role.users)
  role: RoleEntity
}
